package demo6;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String pricestr;
        double price;
        while(true){
            System.out.println("请输入价格");
            try {
                pricestr = scanner.nextLine();
                price = Double.valueOf(pricestr);
            } catch (Exception e) {
                System.out.println("请输入正确的价格！！！");
                continue;
            }
            if(price<=0){
                System.out.println("请输入正数!!!");
            }else{
                System.out.println("你输入了正确的价格:"+price);
                break;
            }
        }
    }
}
